/*
 * $Id: FormatUtil.java 9 2006-03-08 10:21:59Z wjx $
 */
package com.someok.utils.format;



/**
 * Utility methods regarding formatting.
 *
 * <p><a href="FormatUtil.java.html"><i>View Source</i></a></p>
 *
 * @version $Revision: 9 $ $Date: 2006-03-08 18:21:59 +0800 (星期三, 08 三月 2006) $
 */
public final class FormatUtil {

	private static char[] hexDigits = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};

	/**
	 * Returns a hex string representation of a 8 bit integer.
	 * Very fast. Returned hex values are in uppercase.
	 *
	 * @param b      byte to convert to hex string
	 *
	 * @return hex value
	 */
	public static String toHexString(int b) {
		char[] digits = new char[2];
		b = b & 255;

		digits[0] = hexDigits[b / 0x10];
		digits[1] = hexDigits[b % 0x10];

		return new String(digits);
	}
}